package com.qiji.video.web.controller;

import com.qiji.video.bean.VideoPartition;
import com.qiji.video.service.IPartitionService;
import com.qiji.video.util.Result;
import com.qiji.video.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 视频分区管理
 */
@Api(
        tags = {"视频分区模块"}
)
@RestController
@RequestMapping({"/auth/admin/video/partition"})
public class PartitionController {
    @Autowired
    private IPartitionService iVideoPartitionService;

    @ApiOperation("查询所有分区信息")
    @GetMapping("/queryAllPartition")
    public Result findAllVideoType(){
        List<VideoPartition> videoPartitions = iVideoPartitionService.selectPartition();
        return ResultUtil.success(videoPartitions);
    }
    @ApiOperation("根据id删除分区")
    @DeleteMapping("/deletePartitionById")
    public Result deleteTypeById(Integer id){
        iVideoPartitionService.deletePartition(id);
        return ResultUtil.success();
    }
    @ApiOperation("修改分区信息")
    @PostMapping("/updatePartition")
    public Result updateVideoType(VideoPartition videoPartition){
        iVideoPartitionService.updatePartition(videoPartition);
        return ResultUtil.success();
    }
    @ApiOperation("添加分区")
    @PostMapping("/addPartition")
    public Result addVideoType(VideoPartition videoPartition){
        iVideoPartitionService.insertPartition(videoPartition);
        return ResultUtil.success();
    }
}
